<?php

#################################################################
#								HTML
#################################################################

/**
 * EDIT USER PAGE, registed as 'user/profile/edit'
 */

if($_CONTEXT=='HTML'){

	//$_JS_STACK->push(blg_get_site_url().'user/profile/edit.js', TRUE);	
	//$_CSS_STACK->push(blg_get_site_url().'user/profile/edit.css', TRUE);

	//GET USER ENTITY
	$url= blg_get_url_parts();
	$usercode= $url->queries[0]->key;
	$user= blg_get_user_entity_by_code($usercode);
	

	$rows= array();
	$width= 350;
	
	//NAME
	$rows[]= array(
		blg_echo('name'),
		blg_view('element/input', array(
			'name' 	=> 'name',
			'value'	=> $user->name,
			'width' => $width
		))
	);
	
	//USERNAME
	$rows[]= array(
		blg_echo('username'),
		blg_view('element/input', array(
			'name' 	=> 'username',
			'value'	=> $user->username,
			'width' => $width
		))
	);
	
	//EMAIL
	$rows[]= array(
		blg_echo('email'),
		blg_view('element/input', array(
			'name' 	=> 'email',
			'value'	=> $user->email,
			'width' => $width
		))
	);

	//SEXO
	$rows[]= array(
		blg_echo('email'),
		blg_view('element/dropdown', array(
			'name' 	=> 'sexo',
			'description' => 'Elige una opción...',
			'width' => $width,
			'options' => array(
				array('Hombre', 'H'),
				array('Mujer', 'M', TRUE),
				array('Gay', 'G'),
			)
		))
	);	
	
	//EMAIL
	$rows[]= array(
		'Interesado',
		blg_view('element/checkbox', array(
			'name' 	=> 'interesado',
			'value'	=> 'si',
			'label' => 'Estoy interesado en la compraventa de un piso',
			'checked' => TRUE			
		))
	);	
	
	//EMAIL
	$rows[]= array(
		'Interesado',
		blg_view('element/radio', array(
			'name' 	=> 'interesado',
			'value'	=> 'one',
			'label' => 'Estoy interesado en la compraventa de un piso1',
			//'checked' => TRUE			
		))
	);	

	$rows[]= array(
		'Interesado',
		blg_view('element/radio', array(
			'name' 	=> 'interesado',
			'value'	=> 'two',
			'label' => 'Estoy interesado en la compraventa de un piso2',
			//'checked' => TRUE			
		))
	);	

	$rows[]= array(
		'Interesado',
		blg_view('element/radio', array(
			'name' 	=> 'interesado',
			'value'	=> 'three',
			'label' => 'Estoy interesado en la compraventa de un piso3',
			//'checked' => TRUE			
		))
	);	
	
	$rows[]= array(
		'RADIO',
		blg_view('layout/form/radio_list', array(
			'name' => 'asdasdas',
			'options' => array(
				array('Hombre', 'H'),
				array('Mujer', 'M'),
				array('Gay', 'G'),
			),
			'display' => 'col'		
		))
	);	
	
	$rows[]= array(
		'RADIO',
		blg_view('layout/form/radio_list', array(
			'name' => 'asdasdasadasds',
			'options' => array(
				array('Hombre', 'H'),
				array('Mujer', 'M'),
				array('Gay', 'G'),
			),
			'display' => 'row'	
		))
	);	

	$rows[]= array(
		'FILE',
		blg_view('element/file', array(
			'name' => 'myFile',	
			//'width' => $width,
			'image' => 'aqui/muchacho/2.png',
			'extensions' => 'jpg,png,gif' 
		))
	);

	$rows[]= array(
		'',
		blg_view('element/button', array(
			'text' => 'Enviar',
			'submit' => TRUE
		))
	);		
	
	$content= blg_view('layout/table/two_cols', array(
		'data'=> $rows
	));
	
	//$content.= '<img src="http://localhost/blog_php/public_html/file/aqui/muchacho/2.png" />';
	
	$content= blg_view('element/form', array(
		'action' 	=> '#',
		'name'		=> 'miFormulario',
		'id'		=> 'miId',
		'file_upload' => TRUE,
		'content'	=> $content	
	));
		
	echo blg_view('layout/main', array(
		'content'=> $content
	));

}
#################################################################
#								JS
#################################################################
elseif($_CONTEXT=='JS'){ ?>

<?php }
#################################################################
#								CSS
#################################################################
elseif($_CONTEXT=='CSS'){ ?>
	
<?php }
#################################################################
#							  ACCESS
#################################################################
elseif($_CONTEXT=='ACCESS'){
	$url= blg_get_url_parts();	
	$user_exists= blg_usercode_exists($url->queries[0]->key);
	$_ACCESS= (!empty($url->queries[0]->key) && $user_exists);	
}